#ifndef LINKED_LIST_ITERATOR_H
#define LINKED_LIST_ITERATOR_H

#include <iostream>
#include <memory>
#include <utility>
#include <algorithm>
#include <stdexcept>

namespace my_stl {
// 只读，单向移动，单次遍历    
struct input_iterator_tag {};
// 只写，单向移动
struct output_iterator_tag {};
// 可读可写，单向多次遍历
struct forward_iterator_tag : public input_iterator_tag {};
// 支持双向移动
struct bidirectional_iterator_tag : public forward_iterator_tag {};
// 支持随机访问
struct random_access_iterator_tag : public bidirectional_iterator_tag {};

// 迭代器 traits
template<typename Iterator>
struct iterator_traits {
    using difference_type = typename Iterator::difference_type;
    using value_type = typename Iterator::value_type;
    using pointer = typename Iterator::pointer;
    using reference = typename Iterator::reference;
    using iterator_category = typename Iterator::iterator_category;
};

// 针对原生指针的特化
template<typename T>
struct iterator_traits<T*> {
    using difference_type = ptrdiff_t;
    using value_type = T;
    using pointer = T*;
    using reference = T&;
    using iterator_category = random_access_iterator_tag;
};

// 针对常量指针的特化
template<typename T>
struct iterator_traits<const T*> {
    using difference_type = ptrdiff_t;
    using value_type = T;
    using pointer = const T*;
    using reference = const T&;
    using iterator_category = random_access_iterator_tag;
};

// 迭代器基类
template<
    typename Category,
    typename T,
    typename Distance = ptrdiff_t,
    typename Pointer = T*,
    typename Reference = T&
>
struct iterator {
    using iterator_category = Category;
    using value_type = T;
    using difference_type = Distance;
    using pointer = Pointer;
    using reference = Reference;
};
}
  

#endif // LINKED_LIST_ITERATOR_H